/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * OptionsDialog.java
 *
 * Created on 07.08.2009, 13:34:29
 */

package dipl.visualizer.ui;

import org.jdesktop.application.Action;

/**
 *
 * @author Dietmar Walther
 */
public class OptionsDialog extends javax.swing.JDialog {

    /** Creates new form OptionsDialog */
    public OptionsDialog(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
  // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
  private void initComponents() {

    txtL = new javax.swing.JTextField();
    lblL = new javax.swing.JLabel();
    btnClose = new javax.swing.JButton();

    setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
    org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(dipl.visualizer.ui.VisualizerApp.class).getContext().getResourceMap(OptionsDialog.class);
    setTitle(resourceMap.getString("Form.title")); // NOI18N
    setAlwaysOnTop(true);
    setLocationByPlatform(true);
    setModalityType(java.awt.Dialog.ModalityType.APPLICATION_MODAL);
    setName("Form"); // NOI18N
    setResizable(false);

    txtL.setText(resourceMap.getString("txtL.text")); // NOI18N
    txtL.setName("txtL"); // NOI18N

    lblL.setText(resourceMap.getString("lblL.text")); // NOI18N
    lblL.setName("lblL"); // NOI18N

    javax.swing.ActionMap actionMap = org.jdesktop.application.Application.getInstance(dipl.visualizer.ui.VisualizerApp.class).getContext().getActionMap(OptionsDialog.class, this);
    btnClose.setAction(actionMap.get("OnClose")); // NOI18N
    btnClose.setLabel(resourceMap.getString("btnClose.label")); // NOI18N
    btnClose.setName("btnClose"); // NOI18N

    javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
    getContentPane().setLayout(layout);
    layout.setHorizontalGroup(
      layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(layout.createSequentialGroup()
        .addContainerGap()
        .addComponent(lblL)
        .addGap(12, 12, 12)
        .addComponent(txtL, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
        .addContainerGap(197, Short.MAX_VALUE))
      .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
        .addContainerGap(331, Short.MAX_VALUE)
        .addComponent(btnClose)
        .addContainerGap())
    );
    layout.setVerticalGroup(
      layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
      .addGroup(layout.createSequentialGroup()
        .addContainerGap()
        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
          .addComponent(txtL, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
          .addComponent(lblL))
        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 235, Short.MAX_VALUE)
        .addComponent(btnClose)
        .addContainerGap())
    );

    pack();
  }// </editor-fold>//GEN-END:initComponents

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                OptionsDialog dialog = new OptionsDialog(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }

	@Action
	public void OnClose() {
		this.setVisible(false);
	}

	/**
	 * @return L value
	 */
	public int L() {
		try {
			return Integer.parseInt( txtL.getText() );
		}
		catch( Exception e  ) {
			return 0;
		}
	}

	/**
	 * @param L L value
	 */
	public void SetL( int L ) {
		txtL.setText( Integer.toString( L ) );
	}

  // Variables declaration - do not modify//GEN-BEGIN:variables
  private javax.swing.JButton btnClose;
  private javax.swing.JLabel lblL;
  private javax.swing.JTextField txtL;
  // End of variables declaration//GEN-END:variables

}
